<template>
  <div>
    <el-link type="primary" @click="showDetail">
      查看<i class="el-icon-view el-icon--right"></i>
    </el-link>

    <el-dialog title="查看触发条件" :visible.sync="centerDialogVisible" width="30%">
      <div v-for="(item, index) in triggerConditions" :key="index">
        <el-table
          :data="item.expressionList"
          style="width: 100%">
          <el-table-column
            prop="joinStr"
            label="触发条件"
            width="100">
          </el-table-column>
        </el-table>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import { ajax } from "@/store/yg/common/utils";

  export default {
    props: ["row", "data", "more"],
    data() {
      return {
        centerDialogVisible: false,
        discountConfigObj: {},
        triggerConditions: [],
      };
    },

    methods: {
      async showDetail() {
        this.centerDialogVisible = true;
        let req = {};
        req.triggerConditions = this.discountConfigObj.triggerConditions;
        //请求后台
        const { code, data, message } = await ajax(
          "getTriggerConditions",
          req
        );
        if (code !== 200) {
          if (message) {
            this.$message.error(message);
          } else {
            this.$message.error("服务器异常");
          }
          return;
        }
        //请求成功，赋值
        this.triggerConditions = data;
      }
    },
    mounted() {
      this.discountConfigObj = this.data;
    }
  };
</script>

<style>

</style>
